package com.kgc.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kgc.pojo.Provider;
import com.kgc.service.ProviderService;

/**
 * 供应商
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/view/provider")
public class ProviderController {
	
	@Autowired
	private ProviderService providerService;
	
	/**
	 * 获取所有供应商
	 * @return
	 */
	@RequestMapping("/getProviderList.htm")
	@ResponseBody
	public Object getProviderList(){
		Map<String, Object> map = new HashMap<String, Object>();
		
		try {
			List<Provider> list = providerService.getProviderList();
			map.put("result", list);
			map.put("message", "供应商列表查询成功");
			map.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			map.put("success", false);
			map.put("message", "供应商列表查询异常："+e);
		}
		
		return map;
	}
}
